package com.linwen.dataStructure.stack;

public class MyStack {
		private int [] array ;
		private int top;
		//无参构造方法
		public MyStack() {
			array = new int[10];
			top = -1;
		}
		//带参数构造方法
		public MyStack(int size) {
			array = new int[size];
			top = -1;
		}
		//push
		public boolean push(int element) {
			if(top+1==array.length) {
				System.out.println("入栈溢出");
				return false;
			}
			array[++top] = element;
			return true;
		}
		//pop
		public int pop() {
			return array[top--];
		}
		//peek
		public int peek() {
			return array[top];
		}
		//isEmpty
		public boolean isEmpty() {
			return top == -1;
		}
		//isFull
		public boolean isFull() {
			return top == array.length-1;
		}
		
}
